#!/usr/bin/env node

const exp=process.argv[2];

if(typeof(exp)==='undefined'|| exp==='--help'|| exp==='-h'){
  console.log('\
      usage: cmd-name [OPTION] [expression]\n\
      evaluate the expression.\n\
      \n\
    Mandatory arguments to long options are mandatory for short options too.\n\
      -h, --help output help information and exit');
}else{
 calc();
}

function calc() {
  try {
        console.log(`${exp} = ${eval(exp)}`);
          
  } catch(e) {
        console.error(`${exp} 不是合法的数学表达式！`);
          
  }
}

